import { defineStore } from 'pinia'
import exhibition from '../../api/exhibition'

export const useExhibitionStore = defineStore('exhibition', {
  state: () => ({
    // 展览列表数据
    exhibitions: [
      
    ],
    // 分页相关数据
    pageNum: 1,
    pageSize: 6,
    total: 3,
    loading: false,
  }),
  actions: {
    // 获取展览列表数据
    async getExhibitionList() {
      // 模拟API返回数据
      exhibition.getAllExhibition(this.pageNum, this.pageSize).then(res=>{
        this.exhibitions = res.data.data
        this.total = res.data.total
      }).catch(err=>{
        console.log(err)
      })
      return {
        data: {
          data: this.exhibitions,
          total: this.total
        }
      }
    },
    // 更新页码
    updatePageNum(pageNum) {
      this.pageNum = pageNum
    },
    // 更新每页条数
    updatePageSize(pageSize) {
      this.pageSize = pageSize
    },
    changeLoading() {
        this.loading = !this.loading
        setTimeout(() => {
            this.loading = !this.loading
        }, 500);
    },
    
  }
})